package cn.app.utils;

import java.util.List;

public class PageBean<T> {
	//页面会传过来两个数据
	//1.当前页数
	private Integer currentPage;	//2.
	//2.每页显示个数
	private Integer pageSize; 		//5.
	//3.数据总条数	-->通过数据库查询count
	private Integer totalCount;		//13
	
	//4.总页数						  3
	private Integer totalPage;		//totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1
	//5.起始索引						  5
	private Integer startIndex;		// 	(currentPage - 1) * pageSize
	//6.数据
	private List<T> pageList;
	//							2					null				13
	public PageBean(Integer currentPage, Integer pageSize, Integer totalCount) {
		//当前页数
		this.currentPage = currentPage != null && currentPage > 0 ? currentPage : 1;
		//每页显示个数
		this.pageSize = pageSize != null && pageSize > 0 ? pageSize : 5;
		//数据总条数
		this.totalCount = totalCount != null && totalCount > 0 ? totalCount : 0;
		//总页数
		this.totalPage= this.totalCount % this.pageSize == 0 ? this.totalCount / this.pageSize : this.totalCount / this.pageSize + 1;
		//起始索引
		this.startIndex=(this.currentPage - 1) * this.pageSize;
	}
	
	
	public List<T> getPageList() {
		return pageList;
	}





	public void setPageList(List<T> pageList) {
		this.pageList = pageList;
	}






	
	
	
	
	public Integer getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(Integer currentPage) {
		this.currentPage = currentPage;
	}
	public Integer getPageSize() {
		return pageSize;
	}
	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}
	public Integer getTotalCount() {
		return totalCount;
	}
	public void setTotalCount(Integer totalCount) {
		this.totalCount = totalCount;
	}
	public Integer getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(Integer totalPage) {
		this.totalPage = totalPage;
	}
	public Integer getStartIndex() {
		return startIndex;
	}
	public void setStartIndex(Integer startIndex) {
		this.startIndex = startIndex;
	}
	
	
	
	
	
}
